<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@include file="/white/common/taglibs.jsp"%>

<c:set var="ctx" value="${pageContext.request.contextPath}" />

<%
	String theme = getServletContext().getInitParameter("white-theme");
%>

<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>China Telecom Group Yellow Pages</title>
		<link href="${ctx}/white/theme/<%=theme%>/css/commen_0.css"
			rel="stylesheet" type="text/css" />
		<link href="${ctx}/white/theme/<%=theme%>/css/commen.css"
			rel="stylesheet" type="text/css" />
		<link href="${ctx}/white/theme/<%=theme%>/css/main.css"
			rel="stylesheet" type="text/css" />
<script type="text/javascript">

/*Cookie 操作的方法*/
function Cookie(document, name, hours, path, domain, secure)
{
	
	  //alert("Cookie()......");
    this.$document = document;
    this.$name = name;

    if (hours)
        this.$expiration = new Date((new Date()).getTime(  ) + hours*3600000);

    else this.$expiration = null;
    if (path) this.$path = path; else this.$path = null;
    if (domain) this.$domain = domain; else this.$domain = null;
    if (secure) this.$secure = true; else this.$secure = false;
    	
    //alert("Cookie()....OK!");	
}

Cookie.prototype.store = function (  ) {
	  	//alert("Cookie.prototype.store");
	
    var cookieval = "";

    for(var prop in this) {
        if ((prop.charAt(0) == '$') || ((typeof this[prop]) == 'function'))
            continue;
        if (cookieval != "") cookieval += '&';
        cookieval += prop + ':' + escape(this[prop]);
    }

    var cookie = this.$name + '=' + cookieval;
    if (this.$expiration)
        cookie += '; expires=' + this.$expiration.toGMTString(  );

    if (this.$path) cookie += '; path=' + this.$path;
    if (this.$domain) cookie += '; domain=' + this.$domain;
    if (this.$secure) cookie += '; secure';

    this.$document.cookie = cookie;
}

Cookie.prototype.load = function(  ) {
    var allcookies = this.$document.cookie;
    if (allcookies == "") return false;

    var start = allcookies.indexOf(this.$name + '=');
    if (start == -1) return false;
    start += this.$name.length + 1;
    var end = allcookies.indexOf(';', start);
    if (end == -1) end = allcookies.length;
    var cookieval = allcookies.substring(start, end);

    var a = cookieval.split('&');
    for(var i=0; i < a.length; i++)
        a[i] = a[i].split(':');

    for(var i = 0; i < a.length; i++) {
        this[a[i][0]] = unescape(a[i][1]);
    }
    return true;
}
Cookie.prototype.remove = function(  ) {
    var cookie;
    cookie = this.$name + '=';
    if (this.$path) cookie += '; path=' + this.$path;
    if (this.$domain) cookie += '; domain=' + this.$domain;
    cookie += '; expires=Fri, 02-Jan-1970 00:00:00 GMT';

    this.$document.cookie = cookie;
}
//创建Cookie
var logindata = new Cookie(document, "yellow_kp_login_info", 8760);
//读取Cookie的信息
function readCookie()
{
	//alert("readCookie");
  if (!logindata.load(  ) || !logindata.userDomain) {
    document.loginForm.j_username.value = "";
  }else{
    document.loginForm.j_username.value = logindata.userDomain;   
  }
  //alert("readCookie ok!");
}
//保存Cookie
function storeCookie()
{
	//alert("storeCookie");
  logindata.userDomain = document.loginForm.j_username.value; 
  //alert("storeCookie 1"); 
  logindata.store();
}




function submitform() {
	var sumbitform = document.getElementById("loginForm");
	storeCookie();
	sumbitform.submit();
}
</script>
		<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>
	</head>



	<body onkeydown="if(event.keyCode=='13') {loginForm.submit();}" >
		<form method="post" id="loginForm"  name="loginForm"
			action="<c:url value='/loginServlet'/>">
			<table width="800" height="600" align="center" cellpadding="0"
				cellspacing="0">
				<tr>
					<td valign="top"
						background="${ctx}/white/theme/<%=theme%>/White_01.png">
						<table width="100%" cellpadding="0" cellspacing="0">
							<tr>
								<td height="450" colspan="3">
									&nbsp; &nbsp;
									<br />
								</td>
							</tr>
							<tr>
								<td height="110" colspan="2">
									&nbsp;
								</td>
								<td width="550" valign="top">
									<table width="550" cellpadding="0" cellspacing="0"
										align="right" class="text_1" border="0"
										style="width: 300px; height: 85px;" height="85">
										<tr>
											<td width="66" height="24" class="fla_e">
												用户名：
											</td>
											<td align="left">
												<input name="j_username" type="text" id="j_username"

													size="13" value="" />
												<%=request.getAttribute("message")== null ?"" :request.getAttribute("message") %>	

											</td>
										</tr>
										<tr>
											<td width="66" height="24" class="fla_e">
												密 &nbsp;码：
											</td>
											<td align="left">
												<input name="j_password" type="password" id="j_password"
													size="14" value="" />
											</td>
										</tr>
										<tr>
											<td>
												&nbsp;
											</td>
											<td height="35">
												<a href="#" onclick="submitform();return true;"><img
														src="${ctx}/white/theme/default/images/login1.png"
														width="73" height="22" /> </a>
											</td>
										</tr>
									</table>
								</td>
							</tr>
							<tr>
								<td width="18">
									&nbsp;
								</td>
								<td colspan="2" class="text_4">
									Copyright 2012 China Telecom Group Yellow Pages All Rights Reserved
									<br />
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</form>
		
<!--执行Cookie的方法-->
<script>readCookie();</script>		
		
</body>
</html>

